#include "Manager.h"



std::map<std::string,sf::Image*> Manager::images;

sf::Image * Manager::getImage(std::string name)
{
	sf::Image *tempImg;

	if(!searchImage(name,tempImg))
	{
		sf::Image * img = new sf::Image();
		std::string file = "images/" + name + ".png";
		if(!img->LoadFromFile(file))
		{
			std::cout << file << " not found";
			return 0;
		}
		images.insert(std::make_pair(name,img));
		return img;
	}
	return tempImg;
}

bool Manager::searchImage(const std::string &imgName, sf::Image* &tempImg)
{
	std::map<std::string, sf::Image*>::iterator it;
	it = images.find(imgName);
	if(it == images.end())
	{
		return false;
	}
	else{
		tempImg = it->second;
	}
	return true;
}


Manager::Manager()
{

}


Manager::~Manager(void)
{
	images.clear();
}

